<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Slardar script test</title>


  <script>
    (function (i, s, o, g, r, a, m) {
      i['SlardarMonitorObject'] = r;
      (i[r] =
        i[r] ||
        function () {
          (i[r].q = i[r].q || []).push(arguments);
        }),
      (i[r].l = 1 * new Date());
      (a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
      a.async = 1;
      a.src = g;
      m.parentNode.insertBefore(a, m);
      i[r].globalPreCollectError = function () {
        i[r]('precollect', 'error', arguments);
      };
      if (typeof i.addEventListener === 'function') {
        i.addEventListener('error', i[r].globalPreCollectError, true);
      }
      if ('PerformanceLongTaskTiming' in i) {
        var g = (i[r].lt = {
          e: []
        });
        g.o = new PerformanceObserver(l => {
          g.e = g.e.concat(l.getEntries());
        });
        g.o.observe({
          entryTypes: ['longtask']
        });
      }
    })(
      window,
      document,
      'script',
      'http://localhost:8080/cn/browser.cn.js?bid=sdk-script',
      'Slardar'
    );

    window.Slardar('Sentry', Sentry => {
      Sentry.captureMessage('precollect captureMessage');
    });

    window.Slardar('send', 'count', {
      category: 'cypress-precollect',
      action: 'precollect'
    });

    window.Slardar('send', 'timing', {
      category: 'cypress-precollect',
      action: 'precollect',
      value: 1358
    });

    window.Slardar('emit', 'counter', {
      name: 'cypress-precollect',
      value: 1000,
      tags: {
        from: 'cypress-precollect'
      }
    });

    window.Slardar('emit', 'timer', {
      name: 'cypress-precollect',
      value: 1000,
      tags: {
        from: 'cypress-precollect'
      }
    });

    window.Slardar('emit', 'custom', {
      event_name: 'cypress',
      metrics: {
        'cypress-precollect': 1000
      },
      tags: {
        from: 'cypress-precollect'
      }
    });

    window.Slardar('emit', 'log', {
      value: 'cypress-precollect',
      level: 'debug',
      tags: {
        from: 'cypress-precollect'
      }
    });
  </script>
  <link rel="stylesheet" href="https://m.toutiao.com/precollect.css" type="text/css" />

  <script src="https://m.toutiao.com/precollect.js"></script>
  <script type="text/javascript">
    window.loadScript = function (url, callback) {
      var script = document.createElement('script');
      var head = document.head;
      if (callback) {
        script.addEventListener('load', callback);
      }
      script.src = url;
      script.async = true;
      script.crossOrigin = 'anonymous';
      head.insertBefore(script, head.firstChild);
    };
  </script>
  <script type="text/javascript">
    window.loadLink = function (url, callback) {
      var link = document.createElement('link');
      var head = document.head;
      if (callback) {
        link.addEventListener('load', callback);
      }
      link.href = url;
      link.rel = "stylesheet"
      link.type = "text/css"
      head.insertBefore(link, head.firstChild);
    };
  </script>
</head>

<body>
  <div id="app"></div>
</body>

</html>
